import java.util.Random;

public class Lab_01 {
    public static void main(String[] args) {
        Random rand = new Random();
        System.out.println("===== 50 problems of addition and subtraction within 100 =====\n");
        
        for (int i = 1; i <= 50; i++) {
            // Randomly choose addition or subtraction
            int operator = rand.nextInt(2);
            int num1, num2;
            
            if (operator == 0) { // Addition
                num1 = rand.nextInt(100); // Random number between 0-99
                num2 = rand.nextInt(100 - num1); // Ensure sum doesn't exceed 99
                System.out.printf("Problem %2d: %2d + %2d = \n", i, num1, num2);
            } else { // Subtraction
                num1 = rand.nextInt(99) + 1; // Random number between 1-99 as minuend
                num2 = rand.nextInt(num1) + 1; // Ensure positive result
                System.out.printf("Problem %2d: %2d - %2d = \n", i, num1, num2);
            }
            
            // New line every 5 problems for better readability
            if (i % 5 == 0) {
                System.out.println();
            }
        }
        
        System.out.println("\n===== Problem generation completed =====");
    }
}